package com.china08.yxyapi.repository.mg.lecture;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;

import com.china08.yxyapi.entity.mg.lecture.YxyLectureRes;

/**
 * @author Richard.Wang
 * @descript 备授课资源
 */
public interface YxyLectureResRepository extends MongoRepository<YxyLectureRes, String> {

    YxyLectureRes findByResourceIdAndUserIdAndSchoolId(String id, String userId, String schoolId);

    Page<YxyLectureRes> findByUserIdAndSchoolIdAndBookcontentsIdAndFormatId(String userId, String schoolId,
            String bookcontentsId, String formatId, Pageable pageable);

    /**
     * 关键词搜索分页，
     * 
     * @param userId
     * @param schoolId
     * @param bookcontentsId
     * @param keywords
     * @param pageable
     * @return
     */
    Page<YxyLectureRes> findByUserIdAndSchoolIdAndBookcontentsIdAndFormatIdAndResNameContaining(String userId,
            String schoolId, String bookcontentsId, String formatId, String keywords, Pageable pageable);

    Page<YxyLectureRes> findByUserIdAndSchoolIdAndBookcontentsIdAndResNameContaining(String userId, String schoolId,
            String bookcontentsId, String keywords, Pageable pageable);

    Page<YxyLectureRes> findByUserIdAndSchoolIdAndBookcontentsIdAndResNameContainingAndIsDeleteNot(String userId,
            String schoolId, String bookcontentsId, String keywords, Integer isDelete, Pageable pageable);

    Integer countBySchoolIdAndUserIdAndBookcontentsIdAndResourceIdAndIsDeleteNot(String schoolId, String userId,
            String bookcontent, String resEsId, Integer deleteNot);

    Page<YxyLectureRes> findByUserIdAndSchoolIdAndBookcontentsId(String userId, String schoolId, String bookcontentsId,
            Pageable pageable);

    Page<YxyLectureRes> findByUserIdAndSchoolIdAndBookcontentsIdAndIsDeleteNot(String userId, String schoolId,
            String bookcontentsId, Integer isDelete, Pageable pageable);

    YxyLectureRes findByIdAndUserIdAndSchoolId(String id, String userId, String schoolId);

    YxyLectureRes findById(String id);

    Page<YxyLectureRes> findByUserIdAndSchoolIdAndBookcontentsIdAndTypeIdAndIsDeleteNot(String userId, String schoolId,
            String bookcontentsId, String typeId, int i, Pageable pageable);

    Page<YxyLectureRes> findByUserIdAndSchoolIdAndBookcontentsIdAndTypeIdAndResNameContainingAndIsDeleteNot(
            String userId, String schoolId, String bookcontentsId, String typeId, String keyword, int i,
            Pageable pageable);

    Page<YxyLectureRes> findByUserIdAndSchoolIdAndBookcontentsIdAndTypeIdAndResTypeNotAndResNameContainingAndIsDeleteNot(
            String userId, String schoolId, String bookcontentsId, String typeId, int i, String keyword, int j,
            Pageable pageable);

    Page<YxyLectureRes> findByUserIdAndSchoolIdAndBookcontentsIdAndTypeIdAndResTypeNotAndIsDeleteNot(String userId,
            String schoolId, String bookcontentsId, String typeId, int i, int j, Pageable pageable);

    List<YxyLectureRes> findByUserIdAndSchoolIdAndIsDeleteNot(String userId, String schoolId, int i);

    List<YxyLectureRes> findByFileSizeNullOrFileSize(Integer num);

    YxyLectureRes findByResourceId(String resourceId);

    YxyLectureRes findTop1ByResourceId(String resourceId);

}
